﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComTools
{
	internal class OracleHelper
	{
		private static volatile IDbConnection _connection = null;
		private static object syncRoot = new Object();
		private OracleHelper()
		{

		}
		public static IDbConnection GetConnection()
		{
			if (_connection == null)
			{
				lock (syncRoot)
				{
					String r = getConnStr();
					_connection = new Oracle.ManagedDataAccess.Client.OracleConnection(r);
				}
			}
			return _connection;
		}

		private static String getConnStr()
		{
			if (System.Configuration.ConfigurationManager.ConnectionStrings.Count > 0)
			{
				var xx = System.Configuration.ConfigurationManager.ConnectionStrings["ORLCNN"];
				if (xx != null)
				{
					return System.Configuration.ConfigurationManager.ConnectionStrings["ORLCNN"].ConnectionString;
				}
				else
					return String.Empty;
			}
			else
				return String.Empty;
		}
	}
}
